<?php
class users_edit extends SClass {

    public function process() {
        try {
            $user = ServiceUtils::GetFactory()->getUserService()->getUserById($this->getArgument('id'));
            
            if ($this->getControlValue('save')) {
            	ServiceUtils::GetFactory()->getUserService()->editUser(
            	   $user->getId(),
            	   $this->getControlValue('login'),
            	   $this->getControlValue('password'),
            	   $this->getControlValue('name'),
            	   $this->getControlValue('level')
            	);
            	$this->assign('message', 'ok');
            }
            else {
                $this->setControlValue('login', $user->getLogin());
                $this->setControlValue('name', $user->getName());
                $this->setControlValue('level', $user->getLevel());
            }
        } catch (ServiceUtils_Exception $exception) {
            $this->assign('errors', $exception->getErrors());
        }
    }

}